home *** CD-ROM | disk | FTP | other *** search
Lisp/Scheme | 1988-04-07 | 3.2 KB | 95 lines | [TEXT/ttxt] |
- ;; Larry Mulcahy 1988
- ;; character functions
-
- (provide 'character)
-
- (defconstant *ascii-a* (char-int #\a))
- (defconstant *ascii-upper-a* (char-int #\A))
- (defconstant *ascii-z* (char-int #\z))
- (defconstant *ascii-upper-z* (char-int #\Z))
- (defconstant *ascii-0* (char-int #\0))
- (defconstant *ascii-9* (char-int #\9))
- (defconstant *ascii-space* (char-int #\space))
- (defconstant *ascii-delete* 127)
-
- (defconstant *shift-bit* 32)
- (defconstant *control-bit* 64)
- (defconstant *not-shift-bit* (lognot *shift-bit*))
- (defconstant *not-control-bit* (lognot *shift-bit*))
- (defconstant *not-control-shift-bits*
- (lognot (logior *shift-bit* *control-bit*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; turn-on-character-shift-bit
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun turn-on-character-shift-bit (c)
- (int-char (logior (char-int c) *shift-bit*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; turn-on-character-control-bit
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun turn-on-character-control-bit (c)
- (int-char (logior (char-int c) *control-bit*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; turn-off-character-shift-bit
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun turn-off-character-shift-bit (c)
- (int-char (logand (char-int c) *not-shift-bit*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; turn-off-character-control-bit
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun turn-off-character-control-bit (c)
- (int-char (logand (char-int c) *not-control-bit*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; turn-off-character-shift-and-control-bits
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun turn-off-character-shift-and-control-bits (c)
- (int-char (logand (char-int c) *not-shift-control-bits*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; alpha-char-p
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun alpha-char-p (c)
- (let ((n (char-int c)))
- (or (<= *ascii-a* n *ascii-z*)
- (<= *ascii-upper-a* n *ascii-upper-z*))))
-
- ; Now provided by XLISP 2.0
- ;(defun digit-char-p (c)
- ; (let ((n (char-int c)))
- ; (<= *ascii-0* n *ascii-9*)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; alphanumericp
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun alphanumericp (c)
- (let ((n (char-int c)))
- (or (<= *ascii-a* n *ascii-z*)
- (<= *ascii-upper-a* n *ascii-upper-z*)
- (<= *ascii-0* n *ascii-9*))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; whitespacep
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun whitespacep (char)
- (equal (aref *readtable* (char-int char)) :white-space))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; graphic-char-p
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun graphic-char-p (c)
- (let ((n (char-int c)))
- (< *ascii-space* n *ascii-delete*)))
-